﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZBJF.Warranty.BLL;
using ZBJF.Warranty.Model.ViewModel.Log;

namespace ZBJF.Warranty.AdminSite.Controllers
{
    public class OpreateLogsController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public JsonResult Index(OpreateLogsModel model)
        {
            int total;
            var logList =
                ServiceFactory.OpreateLogsServiceInstance.GetPagingList(model, out total)
                    .ToList()
                    .Select(o => new
                    {
                        o.ID,
                        o.CostTotalSecond,
                        o.LogSubject,
                        o.LogContent,
                        CreatedTime = o.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        o.LogTableName,
                        o.LogTablePKID,
                        o.OpreateUserAccount,
                    }).ToList();

            return Json(new
            {
                sEcho = model.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = total,
                aaData = logList
            }, JsonRequestBehavior.AllowGet);
        }
    }
}